<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">


  <link rel="icon" type="image/png" sizes="16x16" href="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/avatar.jpg">

<link rel="stylesheet" href="/next/css/main.css">



<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.3/css/all.min.css" integrity="sha256-2H3fkXt6FEmrReK448mDVGKb3WW2ZZw35gI7vqHOE4Y=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" integrity="sha256-Vzbj7sDDS/woiFS3uNKo8eIuni59rjyNGtXfstRzStA=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"cnhuazhu.gitee.io","root":"/next/","images":"/next/images","scheme":"Mist","version":"8.6.1","exturl":false,"sidebar":{"position":"left","Muse | Mist":320,"display":"post","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":true,"mediumzoom":true,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/next/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/next/js/config.js"></script>
<meta name="description" content="记录数据库系统学习历程">
<meta property="og:type" content="article">
<meta property="og:title" content="数据库学习笔记-数据库简介">
<meta property="og:url" content="https://cnhuazhu.gitee.io/next/2021/03/13/%E6%95%B0%E6%8D%AE%E5%BA%93/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E4%BB%8B/index.html">
<meta property="og:site_name" content="花猪のBlog">
<meta property="og:description" content="记录数据库系统学习历程">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E6%95%B0%E6%8D%AE%E6%93%8D%E4%BD%9C%E6%B5%81%E7%A8%8B.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E6%95%B0%E6%8D%AE%E5%BA%93%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%BB%93%E6%9E%84%E5%B1%82%E6%AC%A1.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E6%95%B0%E6%8D%AE%E5%BA%93%E7%B3%BB%E7%BB%9F%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E5%85%B3%E9%94%AE%E5%AD%97%E6%A1%88%E4%BE%8B.png">
<meta property="article:published_time" content="2021-03-13T13:17:28.000Z">
<meta property="article:modified_time" content="2021-03-14T06:30:32.399Z">
<meta property="article:author" content="花猪">
<meta property="article:tag" content="数据库">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E6%95%B0%E6%8D%AE%E6%93%8D%E4%BD%9C%E6%B5%81%E7%A8%8B.png">


<link rel="canonical" href="https://cnhuazhu.gitee.io/next/2021/03/13/%E6%95%B0%E6%8D%AE%E5%BA%93/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E4%BB%8B/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://cnhuazhu.gitee.io/next/2021/03/13/%E6%95%B0%E6%8D%AE%E5%BA%93/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E4%BB%8B/","path":"2021/03/13/数据库/数据库学习笔记-数据库简介/","title":"数据库学习笔记-数据库简介"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>数据库学习笔记-数据库简介 | 花猪のBlog</title>
  




  <noscript>
    <link rel="stylesheet" href="/next/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/next/" class="brand" rel="start">
      <i class="logo-line"></i>
      <h1 class="site-title">花猪のBlog</h1>
      <i class="logo-line"></i>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-主站"><a href="https://cnhuazhu.top/" rel="noopener" target="_blank"><i class="fas fa-chevron-right fa-fw"></i>主站</a></li>
        <li class="menu-item menu-item-home"><a href="/next/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-tags"><a href="/next/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">14</span></a></li>
        <li class="menu-item menu-item-categories"><a href="/next/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">8</span></a></li>
        <li class="menu-item menu-item-archives"><a href="/next/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">53</span></a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%89%8D%E8%A8%80"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E7%AC%AC%E4%B8%80%E7%AB%A0%EF%BC%9A%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E4%BB%8B"><span class="nav-number">2.</span> <span class="nav-text">第一章：数据库简介</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%9B%B8%E5%85%B3%E6%A6%82%E5%BF%B5"><span class="nav-number">2.1.</span> <span class="nav-text">相关概念</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E7%8E%B0%E6%B5%81%E7%A8%8B"><span class="nav-number">2.2.</span> <span class="nav-text">实现流程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AE%BE%E8%AE%A1"><span class="nav-number">2.3.</span> <span class="nav-text">数据库设计</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E6%A8%A1%E5%9E%8B"><span class="nav-number">2.4.</span> <span class="nav-text">数据模型</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84"><span class="nav-number">2.4.1.</span> <span class="nav-text">数据结构</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E6%A8%A1%E5%9E%8B%E7%9A%84%E5%88%86%E7%B1%BB"><span class="nav-number">2.4.2.</span> <span class="nav-text">数据模型的分类</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E6%A8%A1%E5%9E%8B%E7%9A%84%E7%89%B9%E7%82%B9"><span class="nav-number">2.4.3.</span> <span class="nav-text">数据模型的特点</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%95%B0%E6%8D%AE%E5%BA%93%E8%AF%AD%E8%A8%80"><span class="nav-number">2.5.</span> <span class="nav-text">数据库语言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%B3%E7%B3%BB%E6%A8%A1%E5%9E%8B"><span class="nav-number">2.6.</span> <span class="nav-text">关系模型</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-overview">
            <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="花猪"
      src="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/avatar.jpg">
  <p class="site-author-name" itemprop="name">花猪</p>
  <div class="site-description" itemprop="description">为了获得不同的阅读体验，建立此分站。<br>（可在导航栏搜索想要查看的文章）<br><br>本站主题：NEXT 8.6.1</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/next/archives/">
        
          <span class="site-state-item-count">53</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/next/categories/">
          
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/next/tags/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/CNhuazhu" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;CNhuazhu" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>



          </div>
        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/CNhuazhu" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://cnhuazhu.gitee.io/next/2021/03/13/%E6%95%B0%E6%8D%AE%E5%BA%93/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E4%BB%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/avatar.jpg">
      <meta itemprop="name" content="花猪">
      <meta itemprop="description" content="为了获得不同的阅读体验，建立此分站。<br>（可在导航栏搜索想要查看的文章）<br><br>本站主题：NEXT 8.6.1">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="花猪のBlog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          数据库学习笔记-数据库简介
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2021-03-13 21:17:28" itemprop="dateCreated datePublished" datetime="2021-03-13T21:17:28+08:00">2021-03-13</time>
    </span>
      <span class="post-meta-item">
        <span class="post-meta-item-icon">
          <i class="far fa-calendar-check"></i>
        </span>
        <span class="post-meta-item-text">更新于</span>
        <time title="修改时间：2021-03-14 14:30:32" itemprop="dateModified" datetime="2021-03-14T14:30:32+08:00">2021-03-14</time>
      </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/next/categories/%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" itemprop="url" rel="index"><span itemprop="name">学习笔记</span></a>
        </span>
    </span>

  
    <span id="/next/2021/03/13/%E6%95%B0%E6%8D%AE%E5%BA%93/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E4%BB%8B/" class="post-meta-item leancloud_visitors" data-flag-title="数据库学习笔记-数据库简介" title="阅读次数">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span class="leancloud-visitors-count"></span>
    </span>
    <span id="/next/2021/03/13/%E6%95%B0%E6%8D%AE%E5%BA%93/%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E6%95%B0%E6%8D%AE%E5%BA%93%E7%AE%80%E4%BB%8B/" class="post-meta-item twikoo_visitors" data-flag-title="数据库学习笔记-数据库简介" title="阅读次数">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="twikoo_visitors"></span>
    </span>
  
      </div>
      <div class="post-meta">
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>5.3k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>5 分钟</span>
    </span>
</div>

            <div class="post-description">记录数据库系统学习历程</div>
        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p><em>学习数据库系统，记录笔记。</em></p>
<blockquote>
<p>参考资料：</p>
<p>《数据库系统（设计、实现与管理 第6版, Thomas M.Connolly, Carolyn E.Begg）》</p>
</blockquote>
<hr>
<h1 id="第一章：数据库简介"><a href="#第一章：数据库简介" class="headerlink" title="第一章：数据库简介"></a>第一章：数据库简介</h1><h2 id="相关概念"><a href="#相关概念" class="headerlink" title="相关概念"></a>相关概念</h2><ul>
<li><p><strong>数据（Data）</strong>：Data are raw facts that describe people, objects and events.（数据是描述人、物和事件的原始事实。）</p>
</li>
<li><p><strong>数据存储</strong>：计算机存储数据的方式可以分为两种：<strong>内存</strong>（暂时存储、掉电数据丢失），<strong>外存</strong>（永久存储，掉电数据不丢失）</p>
</li>
<li><p><strong>数据库（DB）</strong>：数据存储的仓库</p>
<p>数据的传递如下图：</p>
<p><img src="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E6%95%B0%E6%8D%AE%E6%93%8D%E4%BD%9C%E6%B5%81%E7%A8%8B.png"></p>
<blockquote>
<p>信息系统包含：</p>
<ul>
<li>事务处理系统（TPS）</li>
<li>在线事务处理系统（OLTP）</li>
<li>供应链管理系统（SCM）</li>
<li>客户关系管理系统（CRM）</li>
<li>企业资源规划系统（ERP）</li>
</ul>
<p>运行数据库可以操作数据：</p>
<p>收集、存储、查看、查找、更新、整理、分类、移动、删除</p>
<p>分析数据库可以提取分析数据：</p>
<ul>
<li>数据挖掘（Data Mining）：找数据关系和模式</li>
<li>预测分析（Predictive Analytics）：分析历史和现在，预测未来</li>
<li>在线分析处理（OLAP）：复杂因素检测</li>
</ul>
</blockquote>
</li>
<li><p><strong>数据库系统（DBS）</strong>：由硬件系统、数据库、数据库管理系统、数据库应用程序、数据库用户等组成的系统。</p>
<p>数据库系统的结构层次如下图：</p>
<p><img src="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E6%95%B0%E6%8D%AE%E5%BA%93%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%BB%93%E6%9E%84%E5%B1%82%E6%AC%A1.png"></p>
<p>基于Web的数据库应用系统工作流程如下：</p>
<p><img src="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E6%95%B0%E6%8D%AE%E5%BA%93%E7%B3%BB%E7%BB%9F%E5%B7%A5%E4%BD%9C%E6%B5%81%E7%A8%8B.png"></p>
</li>
<li><p><strong>数据库管理系统（DBMS）</strong>：A collection of programs that controls，create，maintain，and manipulate databases（一种控制、管理、创建、维护和使用数据库的大型软件）</p>
<blockquote>
<ul>
<li>合理管理和控制数据库中数据</li>
<li>保证数据库中数据的准确、安全、一致性，高效地利用数据</li>
<li>建立在操作系统之上</li>
<li>用户或应用程序发出操作数据库中数据的命令都要通过数据库管理系统来执行</li>
<li>数据的查询是通过数据库管理系统，而并非从数据库直接查询</li>
</ul>
</blockquote>
<p>数据库管理系统的功能：</p>
<ul>
<li>存储、检索、更新数据：用户通过数据库管理系统访问数据库</li>
<li>事务支持：把用户或应用程序的一系列动作看成一个事务</li>
<li>concurrency control under multiple users （多用户并发控制）：多用户并行更新数据库且更新正确</li>
<li>Integrity（完整性）：确保数据库中数据及其的更改遵循规则</li>
<li>Views（视图）：实现程序和数据的独立，隐藏数据的安全机制</li>
<li>Authorization（授权）：授权用户才可以访问</li>
<li>Access controls（访问控制）：Based on the granting and revoking of privileges.（基于权限的授予和回收）</li>
<li>Backup and recovery（备份和恢复）：数据库受到破坏后被恢复</li>
<li>Encryption（加密）：使用特殊算法对数据进行编码，使没有解密密钥的任何程序都无法读取数据。</li>
</ul>
</li>
</ul>
<h2 id="实现流程"><a href="#实现流程" class="headerlink" title="实现流程"></a>实现流程</h2><p>数据库实现流程主要分为<strong>系统设计</strong>阶段以及<strong>系统实现</strong>两个部分：</p>
<ul>
<li>系统设计：又分为3个阶段<ul>
<li>概念数据库设计：所用方法为<strong>E-R建模</strong>模型</li>
<li>逻辑数据库设计：所用方法为<strong>规范化</strong>模式</li>
<li>物理数据库设计</li>
</ul>
</li>
<li>系统实现：依靠数据库语言来实现<ul>
<li>建立数据库的方法：<strong>数据库定义语言（DDL）</strong></li>
<li>操作数据库的方法：<strong>数据库操作语言（DML）</strong></li>
</ul>
</li>
</ul>
<h2 id="数据库设计"><a href="#数据库设计" class="headerlink" title="数据库设计"></a>数据库设计</h2><p>数据库设计要分为三个层次（三层体系结构 The Three-level ANSI-SPARC Achitecture）：</p>
<ul>
<li><strong>外部层</strong>（用户级）（不唯一）：数据库中的部分信息，并非所有信息。<ul>
<li>Users’view of the database.(用户视图)</li>
<li>Describes that part of database that is relevant to a particular user.(和用户相关的数据库部分)</li>
<li>子模式：从模式导出的一个子集</li>
</ul>
</li>
<li><strong>概念层</strong>（概念级）（唯一）：包含库中所有信息。<ul>
<li>Community view of the database.（数据库整体视图）</li>
<li>Describes what data is stored in database and relationships among the data.（数据库的逻辑结构）：数据和数据之间的关系</li>
</ul>
</li>
<li><strong>内部层</strong>（物理级）（唯一）：<ul>
<li>Physical representation of the database on the computer.（物理实现）</li>
<li>Describes how the data is stored in the database.（如何存）</li>
<li>内部表示或底层描述</li>
<li>数据库最低一级的逻辑描述</li>
<li>数据在存储介质上的存储方式和物理结构，对应着实际存储在外存储介质上的数据库</li>
</ul>
</li>
</ul>
<h2 id="数据模型"><a href="#数据模型" class="headerlink" title="数据模型"></a>数据模型</h2><h3 id="数据结构"><a href="#数据结构" class="headerlink" title="数据结构"></a>数据结构</h3><ul>
<li><p>结构化：统一的格式存储数据 （存储形式：关系型数据库）</p>
</li>
<li><p>半结构化：可理解的逻辑流程和格式，格式变化很大（存储形式：非关系型数据库）</p>
</li>
<li><p>非结构化：每份文件独特的格式，结构不规则或不完整，数据模型不固定（存储形式：非关系型数据库）</p>
</li>
</ul>
<h3 id="数据模型的分类"><a href="#数据模型的分类" class="headerlink" title="数据模型的分类"></a>数据模型的分类</h3><p>不同的数据库结构，对应不同的数据库模型。</p>
<p>数据库按照数据模型可分为：</p>
<ul>
<li>Hierarchical Database（层次数据库）</li>
<li>Networked Database（网状数据库）</li>
<li>Relational Database（关系数据库）：现代大多数商业系统采用此模型</li>
<li>Object Database（对象数据库）</li>
<li>Object-Relational（对象关系数据库）</li>
<li>Multi Dimensional Database（多维数据库）</li>
</ul>
<h3 id="数据模型的特点"><a href="#数据模型的特点" class="headerlink" title="数据模型的特点"></a>数据模型的特点</h3><p>数据模型包含3个部分：</p>
<ul>
<li>a structural part（结构部分）</li>
<li>a manipulative part（操作部分）</li>
<li>possibly a set of integrity constraints（完整性规则）</li>
</ul>
<blockquote>
<p>数据模型（Model）与数据模式（Schema）的区别：</p>
<ul>
<li>Schema（模式）：用某一具体的DBMS数据定义语言编写</li>
<li>Model（模型）：比模式更高层次，更抽象地描述数据库</li>
</ul>
</blockquote>
<h2 id="数据库语言"><a href="#数据库语言" class="headerlink" title="数据库语言"></a>数据库语言</h2><p>数据库语言包含两个部分：</p>
<ul>
<li><strong>Data Definition Language（DDL）数据库定义语言</strong>：<ul>
<li>Entities（实体）</li>
<li>Attributes（属性）</li>
<li>Relationships（联系）</li>
<li>Integrity constraints（完整性约束）</li>
<li>Security constraints（安全性约束）</li>
</ul>
</li>
<li><strong>Data Manipulation Language（DML）数据库操作语言</strong>：提供基本的数据处理操作。有两种类型。<ul>
<li>Procedural DML（过程DML）：allows user to tell system exactly how to<br>manipulate data.（需指定如何获得数据）</li>
<li>Non-Procedural DML（非过程DML）：allows user to state what data is needed<br>rather than how it is to be retrieved.（说明需要什么数据）</li>
</ul>
</li>
</ul>
<h2 id="关系模型"><a href="#关系模型" class="headerlink" title="关系模型"></a>关系模型</h2><p>关系模式/关系框架（Relation schema）：A named relation defined by a set of attribute<br>and domain name pairs.（被属性和域定义的关系）</p>
<ul>
<li><p>定义：(A1:D1, A2:D2, … ,An:Dn)</p>
</li>
<li><p>An为属性名；Dn为属性的取值范围</p>
</li>
<li><p>实例：</p>
<table>
<thead>
<tr>
<th>属性（A）</th>
<th>域名</th>
<th>含义</th>
<th>域定义（D）</th>
</tr>
</thead>
<tbody><tr>
<td>branchNo</td>
<td>BranchNumbers</td>
<td>所有可能的分公司编号</td>
<td>4个字符，范围B001~B999</td>
</tr>
<tr>
<td>street</td>
<td>StreetNames</td>
<td>街道名称</td>
<td>25个字符</td>
</tr>
<tr>
<td>city</td>
<td>CityNames</td>
<td>城市名称</td>
<td>15个字符</td>
</tr>
<tr>
<td>postcode</td>
<td>Postcodes</td>
<td>邮编</td>
<td>8个字符</td>
</tr>
<tr>
<td>sex</td>
<td>Sex</td>
<td>性别</td>
<td>1个字符，取值为M或F</td>
</tr>
<tr>
<td>DOB</td>
<td>DatesOfBirth</td>
<td>员工的生日</td>
<td>日期类型，范围从1-1-20起，格式为dd-mmm-yy</td>
</tr>
<tr>
<td>salary</td>
<td>Salaries</td>
<td>员工的工资</td>
<td>7位数字，范围6000.00~40000.00</td>
</tr>
</tbody></table>
</li>
</ul>
<p>Relational database schema（关系数据库模式）：其实就是关系模式的集合</p>
<p>下面以Dreamhome（一个房产销售和租赁公司的数据库系统）案例来理解关系数据库模式：</p>
<blockquote>
<p>表名（属性）：</p>
<p>Branch分公司（branchNo, street, city, postcode）</p>
<p>Staff职员（staffNo, fName, IName, position sex, DOB, salary, branchNo）</p>
<p>PropertyForRent待租房产（propertyNo, street, city, postcode, type, rooms, rent, ownerNo, staffNo, branchNo）</p>
<p>Client客户（clientNo, fName, IName, telNo, prefType, maxRent, eMail）</p>
<p>PrivateOwner私人房产房主（ownerNo, fName, IName, address, telNo, eMail, password）</p>
<p>Viewing看房记录（clientNo, propertyNo, viewDate, comment）</p>
<p>Registration注册记录（clientNo, branchNo, staffNo, dateJoined）</p>
<p>Lease合同（leaseNo, propertyNo, clientNo, rent, paymentMethod, deposit, paid, rentStart, rentStart, rentFinish, duration）</p>
</blockquote>
<p>关系模型（Relational Model）：是一种特殊的数据模型。</p>
<p>包含三要素：</p>
<ul>
<li>Relational Data structure（数据结构）</li>
<li>Relational Data manipulation（数据操纵）</li>
<li>Constraints of data integrity（数据的完整性约束）</li>
</ul>
<p>关系数据模型的相关概念：</p>
<ul>
<li>Attribute（属性）：columns，field（列，字段）：An attribute is a named column of a relation.（属性是关系中命名的列）</li>
<li>Domain（域）：A domain is the set of allowable values for one or more attributes.（属性的取值范围，域是一个或多个属性的取值集合）</li>
<li>Tuple（元组）：row，record（行，记录）：A tuples is a row of relation.（关系中的每一行称为元组）</li>
<li>Degree（维，目，度）：属性的数目（列数）：The degree of a relation is the number of attributes it contains.（关系的维数是指关系所包含属性的个数）</li>
<li>Cardinality（基数）：元组的数目（行数）：The cardinality of a relation is the number of tuples it contains.（关系的基数是指它所包含元组的个数）</li>
<li>Super Key（超关键字）：One or more columns whose values are sufficient to identify a row.（一个属性或属性集合，它能唯一地标识出关系中的每个元组）</li>
<li>Candidate Key（候选关键字）：A super key but no proper subset is a super key.（本身是超关键字但其任何子集都不再是超关键字）：可能有多个</li>
<li>Primary Key（主关键字）：Select one of the candidate keys to use primarily as primary key.（被选用于唯一标识关系中各元组的候选关键字，多个候选关键字中选最合适的一个）</li>
<li>Foreign Key（外部关键字）：An attribute or a set of attributes within a relation that matches the candidate key of some relation。（当一个关系中的某个属性或属性集合与另一个关系（也可是自己）的候选关键字匹配时，就称这个属性或属性集合为外部关键字）</li>
</ul>
<p>下面以Dreamhome关系模式为例进行关键字说明：</p>
<p><img src="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/DB%E5%85%B3%E9%94%AE%E5%AD%97%E6%A1%88%E4%BE%8B.png"></p>
<p>关系完整性：</p>
<ul>
<li><p>Nulls（空）：Null represents a value for an attribute that is currently unknown or is not applicable for this tuple.（代表对一个元组当前取值还不知道或是不可用的属性值。）</p>
</li>
<li><p>Entity Integrity（实体完整性）：</p>
<p>（Candidate）keys must be unique.（关键字值唯一）</p>
<p>In a relation，no attribute of a primary key can be null.（基本表主关键字的诸属性均不能为空）</p>
</li>
<li><p>Referential Integrity （参照完整性）：If a foreign key exists in a relation，either the foreign value must match a candidate key value of some tuple in its home relation or the foreign key value must be wholly null.（外部关键字取参照候选关键字值或取空值）</p>
</li>
<li><p>Enterprise constraints（企业约束）：Additional rules specified by the users or database administrators of a database.（用户和管理员定义的附加规则）</p>
</li>
</ul>

    </div>

    
    
    
      


    <footer class="post-footer">
          <div class="reward-container">
  <div></div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/wechat.png" alt="花猪 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="https://cdn.jsdelivr.net/gh/CNhuazhu/Image/alipay.jpg" alt="花猪 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          <div class="post-tags">
              <a href="/next/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/" rel="tag"><i class="fa fa-tag"></i> 数据库</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/next/2021/03/11/Java/Java-%E7%B1%BB%E5%92%8C%E5%AF%B9%E8%B1%A1/" rel="prev" title="Java--类和对象">
                  <i class="fa fa-chevron-left"></i> Java--类和对象
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/next/2021/03/14/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0-%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%B3%BB%E7%BB%9F%E6%A6%82%E8%BF%B0/" rel="next" title="操作系统学习笔记-计算机系统概述">
                  操作系统学习笔记-计算机系统概述 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments"><div id="twikoo-comments"></div></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">花猪</span>
</div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">356k</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">5:23</span>
  </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/mist/" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

    </div>
  </footer>

  
  <script src="https://cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@next-theme/pjax@0.5.0/pjax.min.js" integrity="sha256-3NkoLDrmHLTYj7csHIZSr0MHAFTXth7Ua/DDt4MRUAg=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script>
  <script src="https://cdn.jsdelivr.net/npm/medium-zoom@1.0.6/dist/medium-zoom.min.js" integrity="sha256-EdPgYcPk/IIrw7FYeuJQexva49pVRZNmt3LculEr7zM=" crossorigin="anonymous"></script>
<script src="/next/js/comments.js"></script><script src="/next/js/utils.js"></script><script src="/next/js/motion.js"></script><script src="/next/js/schemes/muse.js"></script><script src="/next/js/next-boot.js"></script><script src="/next/js/pjax.js"></script>

  
<script src="/next/js/third-party/search/local-search.js"></script>




  


  <script class="next-config" data-name="leancloud_visitors" type="application/json">{"enable":true,"app_id":"dh8GVAcIwU1TN4zhA5y63iW1-gzGzoHsz","app_key":"hzyAqDKjG4OBGrdPS7mKaOa7","server_url":null,"security":true}</script>
  <script src="/next/js/third-party/statistics/lean-analytics.js"></script>


  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/tex-mml-chtml.js","integrity":"sha256-r+3itOMtGGjap0x+10hu6jW/gZCzxHsoKrOd7gyRSGY="}}</script>
<script src="/next/js/third-party/math/mathjax.js"></script>


<script class="next-config" data-name="twikoo" type="application/json">{"enable":true,"visitor":true,"envId":"hexo-1g41404w9f800e94","el":"#twikoo-comments"}</script>
<script>
document.addEventListener('page:loaded', () => {
  NexT.utils.loadComments(CONFIG.twikoo.el)
    .then(() => NexT.utils.getScript(
      'https://cdn.jsdelivr.net/npm/twikoo/dist/twikoo.all.min.js',
      { condition: window.twikoo }
    ))
    .then(() => {
      twikoo.init(CONFIG.twikoo);
    });
});
</script>

</body>
</html>
